Resolve Lakebase .env values in non-interactive apps init#4740
Open
Resolve Lakebase .env values in non-interactive apps init#4740
apps init#4740Conversation
Collaborator
|
Commit: 600d082
20 interesting tests: 9 SKIP, 7 RECOVERED, 4 flaky
Top 20 slowest tests (at least 2 minutes):
|
7538829 to
9f516e6
Compare
b55fc9b to
f282f3a
Compare
f282f3a to
af7233d
Compare
When running `databricks apps init` with `--set` flags (non-interactive mode), the `.env` file had empty values for PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT. These fields have a `Resolve` property that maps them to values derived from the selected branch. In interactive mode, `PromptForPostgres()` runs the full resolution flow, but in non-interactive mode no resolution logic ran. Extract the resolution logic into a new `ResolvePostgresValues()` function and call it from the non-interactive path after `--set` values are merged. Co-authored-by: Isaac
Extract ResolvePostgresValues from PromptForPostgres to reuse resolution of derived postgres fields (host, databaseName, endpointPath) in the non-interactive/flags code path. Consolidate CollectResources calls. Co-authored-by: Isaac
- Restore RunWithSpinnerCtx in interactive PromptForPostgres for the ResolvePostgresValues call to maintain UX feedback during API calls - Add TestResolvePostgresValuesDatabaseAPIError to cover ListDatabases failure path - Fix comment in init.go to say "derived values" instead of "derived postgres values" since the resolve loop is generic Co-authored-by: Isaac
d951298 to
2835416
Compare
Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ResolvePostgresValues()fromPromptForPostgres()so it can be called from the non-interactive code path--setvalues are merged in flags mode, resolve derived postgres fields (host, databaseName, endpointPath) by callingListPostgresEndpointsandListPostgresDatabasesPGHOST,PGDATABASE, andLAKEBASE_ENDPOINTvalues in.envwhen usingdatabricks apps initwith--setflagsRepro command
Rebuild the CLI and run:
dbx apps init --name event-registration \ --features lakebase \ --set "lakebase.postgres.branch=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr" \ --set "lakebase.postgres.database=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/databases/db-5vqi-xormgdrr0m" \ --description "Event registration app with Lakebase" \ --run none --profile DEFAULT --version 0.20.0Then see if .env has filled
PGHOST,PGDATABASE, andLAKEBASE_ENDPOINT:Test plan
go test ./libs/apps/prompt/... ./cmd/apps/...).envhas populated values forPGHOST,PGDATABASE,LAKEBASE_ENDPOINTThis pull request was AI-assisted by Isaac.